<template>
  <div class="mt30">
    <!--form表单-->
    <el-form size="small" ref="form" :model="form" label-width="200px">
      <el-form-item label="提现方式" v-if="list.length > 0">
        <el-checkbox-group v-model="form.payType">
          <el-checkbox
            v-for="(item, index) in list"
            :label="item.value"
            :key="index"
            >{{ item.name }}</el-checkbox
          >
        </el-checkbox-group>
        <div class="tips">
          注：如使用微信支付，则需申请微信支付企业付款到零钱功能
        </div>
      </el-form-item>

      <el-form-item
        label="最低提现额度"
        prop="minMoney"
        :rules="[{ required: true, message: ' ' }]"
      >
        <el-input
          v-model="form.minMoney"
          type="number"
          class="max-w460"
        ></el-input>
      </el-form-item>
      <el-form-item
        label="佣金结算天数"
        prop="settleDays"
        :rules="[{ required: true, message: ' ' }]"
      >
        <el-input
          v-model="form.settleDays"
          type="number"
          class="max-w460"
        ></el-input>
        <div class="tips">
          <p>
            当订单完成n天后，该订单的分销佣金才会结算到分销商余额，如果设置为0天
            则订单完成时就结算
          </p>
          <p class="red">
            注：建议佣金结算天数大于允许发起售后申请天数，如果用户申请退款退货
            则不结算佣金
          </p>
        </div>
      </el-form-item>

      <!--提交-->
      <div class="common-button-wrapper">
        <el-button
          size="small"
          type="primary"
          @click="onSubmit"
          :loading="loading"
          >提交</el-button
        >
      </div>
    </el-form>
  </div>
</template>

<script>
import PlusApi from "@/api/plus.js";

export default {
  data() {
    return {
      /*form表单数据*/
      form: {
        payType: [10],
      },
      list: [],
      selectlist: [10],
      loading: false,
    };
  },
  props: {
    settingData: Object,
  },
  created() {
    this.form = this.settingData.settlement;
    this.list = this.settingData.payType;
    // this.list = [{name:1,value:2},{name:1,value:2}]
  },

  methods: {
    /*提交表单*/
    onSubmit() {
      let self = this;
      let params = self.form;
      self.$refs.form.validate((valid) => {
        if (valid) {
          self.loading = true;
          PlusApi.settlement(params, true)
            .then((data) => {
              self.loading = false;
              ElMessage({
                message: "设置成功",
                type: "success",
              });
            })
            .catch((error) => {
              self.loading = false;
            });
        }
      });
    },
  },
};
</script>

<style></style>
